package com;

import com.fz.entity.Student;
import com.fz.entity.User;
import com.fz.mapper.StudentMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

;


/**
 * Created by Z-C-Y on 2018-02-05.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:beans.xml")
public class Demo {
    @Autowired
    protected User user;

    @Autowired
    protected StudentMapper student;


    @Test
    public void tt() {
        System.out.println(user);
        /*查询所有*/
        System.out.println(student.query());
        /*根据id进行查*/
        Student s = student.queryById(3);
        System.out.println(s);
        /*添加学生*/
      //  Map<String, Object> map = new HashMap<String, Object>();
     //   map.put("name","麻辣");
        //map.put("age",2222);
      //  student.save(map);

        /*根据id进行删除*/
        int i = student.delete(16);
        System.out.println(i);

        /*更改*/
       Student st =  student.queryById(3);
       st.setAge(100);
       student.update(st);

    }

}
